| Conditions | 3 |
| Total Lines | 14 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import {CommandHandler} from '@nestjs/cqrs'; |
||
| 15 | |||
| 16 | public async execute(command: DeleteActivityCommand): Promise<void> { |
||
| 17 | const {activityId, user} = command; |
||
| 18 | const activity = await this.activityRepository.findOneById(activityId); |
||
| 19 | |||
| 20 | if (!(activity instanceof Activity)) { |
||
| 21 | throw new ActivityNotFoundException(); |
||
| 22 | } |
||
| 23 | |||
| 24 | if (activity.getUser().getId() !== user.getId()) { |
||
| 25 | throw new NotActivityOwnerException(); |
||
| 26 | } |
||
| 27 | |||
| 28 | this.activityRepository.deleteById(activityId); |
||
| 29 | } |
||
| 31 |